package com.blood.core.util.bean;

/**
 * @author yelong
 * @date 2020/9/19 16:16
 * @description
 * @Copyright
 */
public class BeanUtils {

    public static <S, T> T copyProperties(S source, Class<T> targetClass) {
        if (source == null) {
            return null;
        }
        try {
            T target = targetClass.newInstance();
            org.springframework.beans.BeanUtils.copyProperties(source, target);
            return target;
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException("拷贝对象异常", e);
        }
    }
}
